package com.vote.www.controller;


import com.vote.www.core.page.Pagination;
import com.vote.www.domain.Czjact;
import com.vote.www.domain.Czjadvertisementimg;
import com.vote.www.domain.Czjbackground;
import com.vote.www.domain.Czjbag;
import com.vote.www.domain.Czjdiscount;
import com.vote.www.domain.Czjuserapprove;
import com.vote.www.domain.Czjuserinfo;
import com.vote.www.domain.Czjusermess;
import com.vote.www.domain.Czjvoteorder;
import com.vote.www.domain.vo.CzjuserapproveVO;
import com.vote.www.domain.vo.OrderTopThird;
import com.vote.www.domain.vo.TorderVO;
import com.vote.www.domain.vo.UserInfoVO;
import com.vote.www.domain.vo.VoteOreder;
import com.vote.www.service.CzjactService;
import com.vote.www.service.CzjadvertisementimgService;
import com.vote.www.service.CzjbackgroundService;
import com.vote.www.service.CzjbagService;
import com.vote.www.service.CzjdiscountService;
import com.vote.www.service.CzjorderService;
import com.vote.www.service.CzjuserapproveService;
import com.vote.www.service.CzjuserinfoService;
import com.vote.www.service.CzjusermessService;
import com.vote.www.service.CzjvoteService;
import com.vote.www.service.CzjvoteorderService;
import com.vote.www.utils.ConvertObj;
import com.vote.www.utils.ImgBase64Util;
import com.vote.www.utils.MapManage;
import com.vote.www.utils.UUIDUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;


@Controller
@RequestMapping("/user")
public class  TuserEditController extends BaseController{
	private static final Logger log = LoggerFactory.getLogger(TuserEditController.class);
	
	private static final Integer MAXUPLOAD_SIZE=52428800;//上传头像最大为50兆
	
	public TuserEditController() {
	}
 

	/**
	 * czj_vote 投票表保存
	 * 
	 * @param czjvote
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("userSave.do")
	public String save(Czjusermess czjusermess, Czjuserinfo czjuserinfo,
			@RequestParam(value = "file", required = false) MultipartFile multipartFiles,
			HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception{
			  String 	userinfoIdParm =  request.getParameter("userinfoId");
			  String  nickParm = request.getParameter("nick");
			  czjusermess.setNick(czjuserinfo.getNickname());	
			  czjusermess.setUserinfoId(Integer.valueOf(userinfoIdParm));
			  czjusermess.setNick(nickParm);
		try {         
			if(czjusermess.getUserinfoId()!=null&&!czjusermess.getUserinfoId().equals("")){
				// 编辑
				
				//路径
				String pathRoot = request.getSession().getServletContext()
						.getRealPath("");
				String path = "";
				// 头像
				if (!multipartFiles.isEmpty() && multipartFiles.getSize()>0) {
					String uuid = UUID.randomUUID().toString().replaceAll("-", "");
					// 获得文件类型（可以判断如果不是图片，禁止上传）
					String contentType = multipartFiles.getContentType();
					// 获得文件后缀名称
					String imageName = contentType.substring(contentType
							.indexOf("/") + 1);
					path = "/upload/" + uuid + "." + "jpg";
					File file = new File(pathRoot + "/upload");
					if (!file.exists()) {
						file.mkdir();
					}
					multipartFiles.transferTo(new File(pathRoot + path));
					
					//更新才删
/*					String jpgPic = czjusermess.getPicPath();
					if(jpgPic.length()>5){
						jpgPic = jpgPic.substring(1, jpgPic.length());
					}
					deleteFile(pathRoot + jpgPic);*/
					//更新才设置图片路径				
						czjusermess.setPicPath(path);
				}
					if("2332453433543543543".equals(czjusermess.getPicPath())){
						czjusermess.setPicPath(null);
					}else{						
						czjusermess.setPicPath(path);
					}
				
				czjuserinfo.setNickname(czjusermess.getNick());				
				//更新扩展表
				if("".equals(czjusermess.getNick())){
					czjusermess.setNick(null);
				}
				if("".equals(czjusermess.getLocus())){
					czjusermess.setLocus(null);
				}
				if("".equals(czjusermess.getContent())){
					czjusermess.setContent(null);
				}
				czjusermessService.updateCzjusermessByUserinfoId(czjusermess);				
				//更新主表
				czjuserinfo.setId(czjusermess.getUserinfoId());
				czjuserinfo.setNickname(czjusermess.getNick());
				if("".equals(czjusermess.getNick())){
					czjuserinfo.setNickname(null);
				}
				czjuserinfoService.updateCzjuserinfo(czjuserinfo);
				//by tangwj
				czjuserapproveService.aotoUpdate(czjusermess.getUserinfoId());
				
				jsonResult(1,"","保存成功","",response);
				//tlogService.insertTloger(LoggerHelper.getTloger(request, LoggerHelper.OPERATING, "编辑czj_vote 投票表", "voteId="+czjvote.getVoteId()));
			} else {
				// 新增
				jsonResult(0,"没有userinfoId","保存失败,系统异常","",response);
					//czjvoteService.insertCzjvote(userInfo);
					
				//tlogService.insertTloger(LoggerHelper.getTloger(request, LoggerHelper.OPERATING, "新增czj_vote 投票表", "voteId="+czjvote.getVoteId()));
			}
			//responseSucess(response);
		} catch (Exception e) {		
			e.printStackTrace();
			jsonResult(0,"错误码","保存失败,系统异常","",response);
		}
		return null;
	}
	
	
	/**
	 * czj_vote 投票表保存
	 * 
	 * @param czjvote
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("userSave1.do")
	public void save1(Czjusermess czjusermess, Czjuserinfo czjuserinfo,
			@RequestParam(required = false)String file,
			@RequestParam(required = false) MultipartFile vo,
			HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception{
			  String 	userinfoIdParm =  request.getParameter("userinfoId");
			  String  nickParm = request.getParameter("nick");
			  czjusermess.setNick(czjuserinfo.getNickname());	
			  czjusermess.setUserinfoId(Integer.valueOf(userinfoIdParm));
			  czjusermess.setNick(nickParm);
//			  String file1 = ImgBase64Util.getImageStr("C:/Users/imssee/Desktop/图片11/2.jpg");//读取D盘  1.jpg
//			  file = file1;
		try {         
			if(czjusermess.getUserinfoId()!=null&&!czjusermess.getUserinfoId().equals("")){
				// 编辑										
				// 头像
				String path ="";
				String pathRoot = request.getSession().getServletContext()
						.getRealPath("");
				if(!"".equals(file)){
				String picName=UUIDUtils.getDateUUID();
				path = "/upload/" +picName + ".jpg";//数据库保存路径
				boolean isTrue= ImgBase64Util.generateImage(file, pathRoot+path);
				if(isTrue==false){
					jsonResult(0, "120", "图片保存失败", "", response);
			        return ;
				  }
				}	
				//czjusermess.setPicPath(path);
					//更新才删
/*					String jpgPic = czjusermess.getPicPath();
					if(jpgPic.length()>5){
						jpgPic = jpgPic.substring(1, jpgPic.length());
					}
					deleteFile(pathRoot + jpgPic);*/

				// 新增视频begin
				Map<String, Object> result = new HashMap<String, Object>();
				if (vo!=null) {
					String contentType = vo.getContentType();
					String voideType = contentType
	                        .substring(contentType.indexOf("/") + 1);

					if (!vo.isEmpty() && vo.getSize() > 0) {
	                    if(vo.getSize()>MAXUPLOAD_SIZE){
	                        jsonResult(0, "114", "视频大小不能大于50M",
	                                result, response);
	                        return;
	                    }
	                    boolean type = volidateVodeType(voideType);
	                    if (type == false) {
	                        jsonResult(0, "112", "上传的视频类型错误，上传的类型只能是 mp4 rmvb avi mov",
	                                result, response);
	                        return;
	                    }
	                    String videoPath =null;
	                    if(voideType.equalsIgnoreCase("quicktime")){
	                    	
	                    	videoPath = "/video/" + vo.getOriginalFilename();
	                    }else{
	                    	videoPath = "/video/" + UUIDUtils.getUUID() + "."
	                                + voideType;
	                    }
	     
	                    File fileDir = new File(pathRoot + "/video");
	                    if (!fileDir.exists()) {
	                        fileDir.mkdir();
	                    }
	                    vo.transferTo(new File(pathRoot + videoPath));
	                    czjusermess.setExt2(videoPath);
	                }else{
	                    czjusermess.setVodeoUri(null);
	                }
				}				
				
				
					//更新才设置图片路径												
					if("".equals(file)){
						czjusermess.setPicPath(null);
					}else{						
						czjusermess.setPicPath(path);
					}
				
				czjuserinfo.setNickname(czjusermess.getNick());				
				//更新扩展表
				if("".equals(czjusermess.getNick())){
					czjusermess.setNick(null);
				}
				if("".equals(czjusermess.getLocus())){
					czjusermess.setLocus(null);
				}
				if("".equals(czjusermess.getContent())){
					czjusermess.setContent(null);
				}
				czjusermess.setExt3(0);
				czjusermessService.updateCzjusermessByUserinfoId(czjusermess);				
				//更新主表
				czjuserinfo.setId(czjusermess.getUserinfoId());
				czjuserinfo.setNickname(czjusermess.getNick());
				if("".equals(czjusermess.getNick())){
					czjuserinfo.setNickname(null);
				}
				czjuserinfoService.updateCzjuserinfo(czjuserinfo);

				//by tangwj
				czjuserapproveService.aotoUpdate(czjusermess.getUserinfoId());
				
				jsonResult(1,"","保存成功","",response);
				//tlogService.insertTloger(LoggerHelper.getTloger(request, LoggerHelper.OPERATING, "编辑czj_vote 投票表", "voteId="+czjvote.getVoteId()));
			} else {
				// 新增
				jsonResult(0,"没有userinfoId","保存失败,系统异常","",response);
					//czjvoteService.insertCzjvote(userInfo);
					
				//tlogService.insertTloger(LoggerHelper.getTloger(request, LoggerHelper.OPERATING, "新增czj_vote 投票表", "voteId="+czjvote.getVoteId()));
			}
			//responseSucess(response);
		} catch (Exception e) {		
			e.printStackTrace();
			jsonResult(0,"错误码","保存失败,系统异常","",response);
			log.error("保存失败,系统异常",e);
		}
	}	
	

//删除更新的图片
 public void deleteFile(String jgpName){	 
	 File f = new File(jgpName); // 输入要删除的文件位置
	 if(f.exists()){
		 f.delete();
	 }
	
 }
	
	/**
	 * czj_vote 投票表详情
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("userFrontEdit.do")
	public String detail(String userinfoId, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
   		Map<String, Object> param = new HashMap<String, Object>();
   		param.put("userinfoId", userinfoId);
   		UserInfoVO userInfoVO = czjuserinfoService.getUserInfoVO(param);
   		if(userInfoVO!=null){
   		userInfoVO.setVoteNum(czjuserinfoService.voteNum(param));
   		}
   		Integer old = 0;
   		Integer now = Integer.valueOf(new SimpleDateFormat("yyyy").format(new Date()));
   		if(userInfoVO.getIdCard().length()>14){
   			old = Integer.valueOf(userInfoVO.getIdCard().substring(6, 10));
   		}
   		userInfoVO.setAge(now-old);
			//responseSucess(czjvote, response);
   		jsonResult(1,"","",userInfoVO,response);
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"","获取用户信息失败","",response);
			log.error("获取用户信息失败",e);
			
		}
		return null;
	}

	
	/**
	 * czj_vote 投票表详情
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("userEdit.do")
	public String detail11(String userinfoId, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
   		Map<String, Object> param = new HashMap<String, Object>();
   		param.put("userinfoId", userinfoId);		
   		CzjuserapproveVO  czjuserapproveVO = new CzjuserapproveVO();
   		    try {
   		   		czjuserapproveVO = (CzjuserapproveVO) jdbcTemplate.queryForObject("select * from czj_userapprove where userinfoId='"+userinfoId+"' and isuse='1' limit 1",new BeanPropertyRowMapper(CzjuserapproveVO.class));
			} catch (Exception e) {
				czjuserapproveVO = (CzjuserapproveVO) jdbcTemplate.queryForObject("select * from czj_userapprove where userinfoId='"+userinfoId+"' and isuse='0' ORDER BY createtime desc limit 1",new BeanPropertyRowMapper(CzjuserapproveVO.class));
			} 
   		
   		if(czjuserapproveVO!=null){
   			czjuserapproveVO.setVoteNum(czjuserinfoService.voteNum(param));
   		}
   		Integer old = 0;
   		Integer now = Integer.valueOf(new SimpleDateFormat("yyyy").format(new Date()));
   		if(czjuserapproveVO.getIdCard().length()>14){
   			old = Integer.valueOf(czjuserapproveVO.getIdCard().substring(6, 10));
   		}
   		czjuserapproveVO.setAge(now-old);
			//responseSucess(czjvote, response);
   		jsonResult(1,"","",czjuserapproveVO,response);
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"","获取用户信息失败","",response);
			
		}
		return null;
	}	
	
	
	/**
	 * 昨天增长速度最快
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("voteorder.do")
	public String detail1233( HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
			//获取昨天的投票数
			  Calendar   cal   =   Calendar.getInstance();
			  cal.add(Calendar.DATE,   -1);
			  String yesterday = new SimpleDateFormat( "yyyy-MM-dd ").format(cal.getTime());
			  System.out.println(yesterday);
	          Map <String,Object> param = new HashMap<String, Object>();
	          param.put("yesterdayStr", yesterday);

	          Czjvoteorder czjvoteorderisNull = czjvoteorderService.getCzjvoteorderByvoteDate(param);          
	          //czjvoteorderisNull 为空插入数据库
	         if(czjvoteorderisNull==null){  
	        	 List<VoteOreder>  listOreder  =  czjvoteorderService.getVoteOreder(param);
	        	 if(listOreder.size()>0){          
		        //插入数据库  	                 
	                 Czjvoteorder czjvoteorder1 = new Czjvoteorder();//new新的czjvoteorder
		          if(listOreder.size()>0){		        	  
		        	  czjvoteorder1.setUserinfoIdFirst(listOreder.get(0).getUserinfoId());
		        	  czjvoteorder1.setExt1(listOreder.get(0).getNick());
		        	  czjvoteorder1.setExt4(listOreder.get(0).getPicPath());
		        	  czjvoteorder1.setNumFirst(listOreder.get(0).getNum());
		        	  czjvoteorder1.setRepresent1(listOreder.get(0).getRepresent());
		        	  if(listOreder.get(0).getPicPathPng()!=null){
		        		 czjvoteorder1.setImgFirst(listOreder.get(0).getPicPathPng());  
		        	  }else{
		        		  czjvoteorder1.setImgFirst(listOreder.get(0).getPicPath()); 
		        	  }	
		          }
		          if(listOreder.size()>1){
		          czjvoteorder1.setUserinfoIdSecond(listOreder.get(1).getUserinfoId());
		          czjvoteorder1.setExt2(listOreder.get(1).getNick());
		          czjvoteorder1.setExt5(listOreder.get(1).getPicPath());
		          czjvoteorder1.setNumSecond(listOreder.get(1).getNum());
		          czjvoteorder1.setRepresent2(listOreder.get(1).getRepresent());
		        	  if(listOreder.get(1).getPicPathPng()!=null){
		        		 czjvoteorder1.setImgSecond(listOreder.get(1).getPicPathPng());  
		        	  }else{
		        		  czjvoteorder1.setImgSecond(listOreder.get(1).getPicPath()); 
		        	  }	
		          }		          
		          if(listOreder.size()>2){
		          czjvoteorder1.setUserinfoIdThird(listOreder.get(2).getUserinfoId());
		          czjvoteorder1.setExt3(listOreder.get(2).getNick());
		          czjvoteorder1.setExt6(listOreder.get(2).getPicPath());
		          czjvoteorder1.setNumThird(listOreder.get(2).getNum());
		          czjvoteorder1.setRepresent3(listOreder.get(2).getRepresent());
		        	  if(listOreder.get(2).getPicPathPng()!=null){
		        		 czjvoteorder1.setImgThird(listOreder.get(2).getPicPathPng());  
		        	  }else{
		        		  czjvoteorder1.setImgThird(listOreder.get(2).getPicPath()); 
		        	  }	
		          }
		          if(listOreder.size()!=1 && listOreder.size()!=2){
			          czjvoteorder1.setIsRelease(1);
			          czjvoteorder1.setVoteDate(yesterday);
			          czjvoteorder1.setCreatetime(new Date());
			          czjvoteorderService.insertCzjvoteorder(czjvoteorder1);
		          } 
              }
          }				
	            	          
	        //判断是否为空  
	        Czjvoteorder czjvoteorder = czjvoteorderService.getCzjvoteorderByvoteDate(param);	        
	        //给接口的数据
	        if(czjvoteorder!=null && czjvoteorder.getIsRelease() == 1){
	            	List<OrderTopThird>  list = new ArrayList<OrderTopThird>();	            	
	            	OrderTopThird orderTopThird1 = new OrderTopThird();
	            	orderTopThird1.setUserinfoId(czjvoteorder.getUserinfoIdFirst());
	            	orderTopThird1.setImgPic(czjvoteorder.getImgFirst());
	            	orderTopThird1.setNick(czjvoteorder.getExt1());
	            	orderTopThird1.setNum(czjvoteorder.getNumFirst());
	            	orderTopThird1.setRepresent(czjvoteorder.getRepresent1());
	            	OrderTopThird orderTopThird2 = new OrderTopThird();
	            	orderTopThird2.setUserinfoId(czjvoteorder.getUserinfoIdSecond());
	            	orderTopThird2.setImgPic(czjvoteorder.getImgSecond());
	            	orderTopThird2.setNick(czjvoteorder.getExt2());
	            	orderTopThird2.setNum(czjvoteorder.getNumSecond());
	            	orderTopThird2.setRepresent(czjvoteorder.getRepresent2());
	            	OrderTopThird orderTopThird3 = new OrderTopThird();	
	            	orderTopThird3.setUserinfoId(czjvoteorder.getUserinfoIdThird());
	            	orderTopThird3.setImgPic(czjvoteorder.getImgThird());
	            	orderTopThird3.setNick(czjvoteorder.getExt3());
	            	orderTopThird3.setNum(czjvoteorder.getNumThird());
	            	orderTopThird3.setRepresent(czjvoteorder.getRepresent3());
	            	list.add(orderTopThird1);
	            	list.add(orderTopThird2);
	            	list.add(orderTopThird3);
	        	jsonResult(1,"","获取投票前三名信息成功",list,response);
	        }else{
	        	jsonResult(1,"","获取投票前三名信息失败或者没发布",null,response);
	        }
					
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"202","获取投票前三名信息失败,系统异常","",response);
			log.error("获取投票前三名信息失败,系统异常",e);
			
		}
		return null;
	}		
	
	/**
	 * 广告轮播
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("advertisementList.do")
	public void detail1233dsf( HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("ext1",1 );
			List<Czjadvertisementimg>  list = czjadvertisementimgService.getCzjadvertisementimgListALL(param);
			
			List<Map<String,Object>> listmap = ConvertObj.toListMap(list);
			MapManage.returnReservedForListMap(listmap, new String[]{"imgUrl","imgPath"});
			jsonResult(1,"","获取广告列表信息成功",listmap,response);
						
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"204","获取广告列表信息错误,系统异常","",response);
			log.error("获取广告列表信息错误,系统异常",e);
			
		}
		
	}	
	
	
	/**
	 * 超值专享
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("discountList.do")
	public void detail1gag( HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("ext1",1 );
			List<Czjdiscount>  list = czjdiscountService.getCzjdiscountListALL(param);		
			List<Map<String,Object>> listmap = ConvertObj.toListMap(list);
			MapManage.returnReservedForListMap(listmap, new String[]{"imgUrl","imgPath","remark"});
			jsonResult(1,"","获取超值专享图片信息成功",listmap,response);
						
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"208","获取超值专享图片信息错误,系统异常","",response);
			log.error("获取超值专享图片信息错误,系统异常",e);
			
		}
		
	}		
	
	/**
	 * 包包
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("bagList.do")
	public void detailbag( HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("ext1",1 );
			List<Czjbag>  list = czjbagService.getCzjbagListALL(param);		
			List<Map<String,Object>> listmap = ConvertObj.toListMap(list);
			MapManage.returnReservedForListMap(listmap, new String[]{"bagId","imgPath","remark"});
			jsonResult(1,"","获取包包图片信息成功",listmap,response);
						
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"208","获取包包图片信息错误,系统异常","",response);
			log.error("获取包包图片信息错误,系统异常",e);
			
		}
		
	}	
	
	
	/**
	 * 背景
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("backgroundList.do")
	public void detailbackground( HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("ext1",1 );
			List<Czjbackground>  list = czjbackgroundService.getCzjbackgroundListALL(param);		
			List<Map<String,Object>> listmap = ConvertObj.toListMap(list);
			MapManage.returnReservedForListMap(listmap, new String[]{"imgPath"});
			jsonResult(1,"","获取背景图片信息成功",listmap,response);
						
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"208","获取背景图片信息错误,系统异常","",response);
			log.error("获取背景图片信息错误,系统异常",e);
			
		}
		
	}		
	
	/**
	 * 活动
	 * 
	 * @param voteId
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("actList.do")
	public void detailact( HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		try {
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("ext1",1 );
			List<Czjact>  list = czjactService.getCzjactListALL(param);		
			List<Map<String,Object>> listmap = ConvertObj.toListMap(list);
			MapManage.returnReservedForListMap(listmap, new String[]{"actId"});
			jsonResult(1,"","获取活动信息成功",listmap,response);
						
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0,"208","获取活动信息错误,系统异常","",response);
			log.error("获取活动信息错误,系统异常",e);
			
		}
		
	}	
	

	/**
	 * 车主节订单
	 * 
	 * @param request
	 * @param model
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("orderList.do")
	public void detailorder( @RequestParam(required=true) String userInfoId, Integer pageNo,
			String order,String sort,
			HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception {
	      try {   
	     		if (pageNo == null)
	     			pageNo = 1;
	     		Map<String, Object> param = new HashMap<String, Object>();
	     		param.put("userInfoId",userInfoId);
	     		param.put("isShow",1);
	     		param.put("isDel",1);

			  Pagination pagination = czjorderService.getListCzjOrder(param);
//	           Pagination pagination = czjorderService.getCzjorderListOther(param, 10000, pageNo,
//	     				order, sort);
	           
	       
	           
	           jsonResult(1, "", "订单信息列表成功", pagination, response);
	           
		   } catch (Exception e) {
			jsonResult(0, "", "订单信息列表失败", "", response);
			log.error("czjbackground listPage error:", e);
			throw e;

		   }
	  	}		
	
	/**
	 * 车主节订单详情
	 * 
	 * @param request
	 * @param model
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("orderDetails.do")
	public void detailorder123( @RequestParam(required=true) String orderId, Integer pageNo,
			String order,String sort,
			HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception {
	      try {   
	    	  Map<String, Object> param = new HashMap<String, Object>();
	    	   param.put("orderId", orderId);	    	  
	    	 TorderVO torderVO = czjorderService.getOrderDetails(param);  
		    	 if("7月深圳多彩跑".equals(torderVO.getRemark())){
		    		 torderVO.setBagOrAct(1);
		    	 }else{
		    		 torderVO.setBagOrAct(2);
		    	 }	    	 
	           jsonResult(1, "", "订单详情信息成功", torderVO, response);	           
		   } catch (Exception e) {
			jsonResult(0, "205", "订单详情信息失败,系统错误", "", response);
			log.error("orderDetails  error:", e);
			throw e;

		   }
	  	}	
	
	
	
	
	public boolean volidateVodeType(String type) {
		if (type.equalsIgnoreCase("mp4") || type.equalsIgnoreCase("avi")
				|| type.equalsIgnoreCase("rmvb"))
			return true;
		else
			return false;
	}	

	
    @Resource
    private CzjorderService czjorderService;
	
	@Resource
	private CzjadvertisementimgService czjadvertisementimgService;	
	
	@Resource
	private CzjdiscountService czjdiscountService;	
	
	@Resource
	private CzjbagService czjbagService;	
	
	@Resource
	private CzjbackgroundService czjbackgroundService;	
	
	@Resource
	private CzjactService czjactService;		
	
	@Resource
	private CzjvoteorderService czjvoteorderService;
	
	@Resource
	private CzjuserinfoService czjuserinfoService;
	 
	@Resource
	private CzjusermessService czjusermessService;;
	
	@Resource
	private CzjvoteService czjvoteService;
	@Autowired
	private CzjuserapproveService czjuserapproveService;
	@Autowired
	private JdbcTemplate jdbcTemplate;

}